package com.itheima.tlais_web_management.controller;

import com.itheima.tlais_web_management.pojo.PageBean;
import com.itheima.tlais_web_management.pojo.Result;
import com.itheima.tlais_web_management.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class MovieController {

    @Autowired
    private MovieService movieService;

    @GetMapping("movie")
    public Result list(String name,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "5") Integer pageSize){

        PageBean pageBean = movieService.list(name, page, pageSize);

        return Result.success(pageBean);
    }

    @DeleteMapping("movie/{ids}")
    public Result deletebyids(@PathVariable List<Integer> ids){

        movieService.deletebyids(ids);

        return Result.success();
    }

}
